home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / ResExpress 1.0.1.sea / ResExpress 1.0.1 ƒ / ResX DevKit / Think Pascal / ResX Utils.p < prev    next >
Text File  |  1991-07-06  |  8KB  |  169 lines

  1. {ResX Utils is a library to be used for ResX externals and views.}
  2. {It can only be used with ResX and any attempt to use it with another}
  3. {project may be very hazardous to your health because it relies on the}
  4. {presents of ResX to work.}
  5.  
  6.  
  7.  
  8. unit ResXUtils;    {Version 1.1}
  9.  
  10.  
  11. interface
  12.     type
  13.         SettingsHandle = ^SettingsPtr;                        {Contains Configuration setup, last and second}
  14.         SettingsPtr = ^SettingsRec;                            {to last files opened, and last move info}
  15.         SettingsRec = record
  16.                 unused1: Boolean;
  17.                 openStartup: Boolean;                            {Enable/Disable Open on Startup options}
  18.                 sortTList, sortRList: Boolean;                    {Sort Type/Resource list}
  19.                 lastOneRefNum, lastTwoRefNum: integer;        {Last/Second to last volume reference number}
  20.                 lastOneName, lastTwoName: Str255;            {Last/Second to last file name}
  21.                 lastMoveType: ResType;                        {TYPE of the last resource copied}
  22.                 lastMoveID: integer;                                {Resource ID of the last resource copied}
  23.                 lastMoveSource, lastMoveDest: Str255;        {Source and Dest Files of the last resource copied}
  24.                 onStartup: integer;                                {Open on startup option: 1-Last File, 2-Last Two Files, 3-Open File Dialog}
  25.                 unused2: integer;
  26.                 dClick: integer;                                    {Current selected item of DoubleClick popup menu}
  27.                 helpFName: Str255;                                {Location of master Help file}
  28.             end;
  29.  
  30.  
  31.  
  32.         GlobalsHndl = ^GlobalsPtr;                            {ResX Global Data - Some data can be programmably}
  33.         GlobalsPtr = ^GlobalsRec;                            {altered.  Alter with care!    * denotes DO NOT alter}
  34.         GlobalsRec = record
  35.                 theDevCtlEnt: DCtlPtr;                            {*Device Control Entry for DA*}
  36.                 rsrcBase: Integer;                                {*Resource Base*}
  37.                 daMenu: MenuHandle;                            {Main DA Menu}
  38.                 daFileID: Longint;                                    {*File ID of DA*}
  39.  
  40.                 LeftFName, RightFName: Str255;                {Path and Name of Left & Right files currently opened}
  41.                 LeftVNum, RightVNum: integer;                    {vRefNum of Left & Right files}
  42.                 LWasOpened, RWasOpened: Boolean;            {Left/Right file was opened priorly and shouldn't be closed}
  43.                 LcurType, RcurType: ResType;                    {Current type displayed above resource lists}
  44.                 LTcurCell, RTcurCell: Cell;                        {Current selected cell in Left/Right TYPE list}
  45.                 LRcurCell, RRcurCell: Cell;                        {Current selected cell in Left/Right RESOURCE list}
  46.                 LfileID, RfileID: integer;                            {Left/Right File ID}
  47.                 prefsID: integer;                                    {File ID of ResX Prefs in the System Folder}
  48.                 CompactLeft, CompactRight: Boolean;            {Left/Right resource map will be compacted when closed if TRUE}
  49.                 favMenu, extMenu, openMenu: MenuHandle;    {*Favorite File/Externals/Open File MenuHandles}
  50.                 Lopen, Ropen: Boolean;                            {True if Left/Right file is open and displayed in ResX}
  51.                 MFActive: Boolean;                                {*True if MultiFinder is running*}
  52.                 Settings: SettingsHandle;                        {Handle to Settings in Configuration setup}
  53.  
  54.                 LTypeList: ListHandle;                            {Handle to Left Type list}
  55.                 RTypeList: ListHandle;                            {Handle to Right Type list}
  56.                 LResList: ListHandle;                                {Handle to Left Resource list}
  57.                 RResList: ListHandle;                            {Handle to Right Resource list}
  58.  
  59.                 Info: ControlHandle;                               {Get Info Button Control Handle}
  60.                 View: ControlHandle;                               {View Button Control Handle}
  61.                 OpenLeft: ControlHandle;                           {Open Left Button Control Handle}
  62.                 OpenRight: ControlHandle;                          {Open Right Button Control Handle}
  63.                 Remove: ControlHandle;                             {Remove Button Control Handle}
  64.                 Copy: ControlHandle;                               {Copy Button Control Handle}
  65.  
  66.  
  67.             end;                                                    {DO NOT alter globals denoted with *.  They can}
  68.                                                             {be accessed for reference only.}
  69.  
  70.  
  71. {ResX Toolbox}
  72.  
  73.     procedure CenterWindow (theWindow: WindowPtr);
  74.     procedure GetCenterPoint (var thePoint: Point);
  75.     procedure MoveBWindow (theWindow: WindowPtr; PrevWindowRect: Rect; var windFlag: Boolean);
  76.  
  77.     function ShortFName (LongName: Str255): Str255;
  78.  
  79.     procedure GetDirInfo (vRefNum: Integer; vName: StringPtr; var wdDirID: Longint);
  80.     function TestColor: Boolean;
  81.     function TrackRect (theRect: Rect): Boolean;
  82.  
  83.  
  84.  
  85. {Internal Alerts -}
  86. {    The following Alerts allow direct access to the Alerts internal to ResX.  When a }
  87. {     message or question is passed in, the Alert resources inside of ResX are used.  }
  88. {    This simplifies writing externals for ResX by leaps and bounds since the }
  89. {    developer does not need to program for these common procedures.}
  90.  
  91.     function OKCancel (Message: Str255): boolean;  {TRUE if OK is clicked, FALSE if Cancel is clicked}
  92.     procedure OKAlert (Message: Str255);
  93.     function YesNoCancel (Question: Str255): integer; { Yes=1, No=0, Cancel=-1}
  94.  
  95.  
  96.  
  97.  
  98.     function SelectFile: integer;
  99. {SelectFile -}
  100. {    This function checks to see if a file is opened within ResX.  If only one file is opened, }
  101. {    it's fileID will be returned.  If two files are opened, a dialog will appear and ask to select}
  102. {    file.  The fileID of the file selected will be returned.  If the user cancels from the dialog,}
  103. {    a zero will be returned.  If no files are opened, a -1 will be returned.}
  104. {    }
  105. {    The resource to the dialog exists inside of ResX.}
  106.  
  107. {    Result Codes:  }
  108. {                -1: No file open.}
  109. {                  0: Cancel was selected.}
  110. {                >0: fileID of the file selected.}
  111.  
  112.  
  113.     function TrapAvailable (theTrap: Integer): Boolean;
  114. {TrapAvailable -}
  115. {    Determines if a toolbox trap is available.  theTrap is the trap address to test.}
  116. {    Example:}
  117. {        if TrapAvailable(_OSDispatch) then .....}
  118.  
  119.  
  120.  
  121. {Super Memory Manager}
  122.  
  123. {The Super Memory Manager is the best of the standard memory routines and the}
  124. {Temporary memory routines.  It tests to see if the Temporary Memory Routines}
  125. {exists and uses it if there is more memory available in the free space than in the }
  126. {current heap.  If the blockSize requested is not available, it returns 90% of the}
  127. {maximum available memory that can be obtained from either the current heap or}
  128. {the free space heap, whichever is greater.}
  129.  
  130. {HType is used by the Super Memory Manager to determine what type of handle was}
  131. {created.  HType must NOT be altered at any time.  It is necessary to dispose of a}
  132. {SuperHandle properly.}
  133.  
  134.  
  135.  
  136.     function SuperNewHandle (blockSize: Size; var HType: Boolean; var resultCode: OSErr): Handle;
  137. {SuperNewHandle - }
  138. {        blockSize    -    requested amount of memory to create a handle for.  If the requested amount}
  139. {                        is not available, 90% of the available memory is returned.}
  140. {        HType        -    returns the type of handle that was created.  True if Temporary, False if Standard.}
  141. {                              Do not alter HType!  Alway use it to pass into Lock,Unlock and Dispose procedures.}
  142. {        resultCode-     the standard MemError result.}
  143. {        RETURNS    -    a standard Handle.}
  144. {}
  145. {        If blockSize requested is not available, 90% of the maximum available memory is used.}
  146. {        Use SizeOf(myHandle) to determine the size of the handle if needed.}
  147.  
  148.  
  149.     procedure SuperHLock (theHandle: Handle; HType: Boolean; var resultCode: OSErr);
  150. {SuperHLock - }
  151. {        theHandle    -    the Super handle to lock}
  152. {        HType        -    the type of handle provided by SuperNewHandle.}
  153. {        resultCode-     the standard MemError result.}
  154.  
  155.     procedure SuperHUnLock (theHandle: Handle; HType: Boolean; var resultCode: OSErr);
  156. {SuperHUnLock - }
  157. {        theHandle    -    the Super handle to UNlock}
  158. {        HType        -    the type of handle provided by SuperNewHandle.}
  159. {        resultCode-     the standard MemError result.}
  160.  
  161.     procedure SuperDisposHandle (theHandle: Handle; HType: Boolean; var resultCode: OSErr);
  162. {SuperDisposHandle - }
  163. {        theHandle    -    the Super handle to Dispose of.}
  164. {        HType        -    the type of handle provided by SuperNewHandle.}
  165. {        resultCode-     the standard MemError result.}
  166.  
  167.  
  168. implementation
  169. end.